#include<bits/stdc++.h>
#include"Quicksort.hpp"
using namespace std;

vector<int> data1,data2,data3;

int main(){
    int n,x;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        data1.push_back(x);
        data2.push_back(x);
        data3.push_back(x);
    }

    sort_MoT(data1);

    sort_random(data2);

    sort_average(data3);
    
    for(long unsigned int i=0;i<data1.size();i++){
        if(data1[i]!=data2[i]||data1[i]!=data3[i]){
            cout<<"Error!"<<endl;
            break;
        }
    }
    for(long unsigned int i=0;i<data1.size();i++) cout<<data1[i]<<' ';
    cout<<endl;
}